package com.wty.example.unmodifyobj;

import com.google.common.collect.Lists;

import java.util.Collections;
import java.util.List;

public class CollectionsDemo {

    public static void main(String args[]) {
        List list=Lists.newArrayList();
        test1(list);
        System.out.println(list.size());


        //会报错
        List unmodifyList=Collections.unmodifiableList(list);
        test1(unmodifyList);
        System.out.println(unmodifyList.size());
    }


    public static void test1(List list) {
        list.add("wty");
        list.add("tyty");
    }

}
